<?php
namespace app\index\controller;


use think\Controller;
use think\Db;
use think\Validate;
use app\admin\common\Constants;
use AntCloudSDKCore\AntCloudClient;
use think\Log;
use think\Queue;

class Index extends Controller
{
	        //function __construct()
    //{
    //    $this->db_app = Db::connect('database_app');
    //}
	    public function ces()
    {	
		$list=$this->db_app->table('tp_user')->limit(0,10)->select();
		return apireturn(1,'成功',$list); 
    }
    public function index()
    {	
    	// echo '1233';
    	return $this->fetch();
    }
    public function about_us()
    {
    	return $this->fetch();
    }
        public function contact_us()
    {
    	return $this->fetch();
    }
        public function news()
    {
    	return $this->fetch();
    }
        public function news1()
    {
    	return $this->fetch();
    }
        public function reg()
    {
    	return $this->fetch();
    }
        public function xieyi()
    {
    	return $this->fetch();
    }
    public function test(){
	    $token = input("__token__");//获取提交过来的令牌
	    $data = [
		    '__token__' => $token,
	    ];
	    //验证路由
	    $rule = [
		    '__token__' => 'token',
	    ];
	    //错误信息
	    $msg = [
		    '__token__'  => '请不要刷新该页面！',
	    ];
	    //引入验证类
	    $validate   = Validate::make($rule,$msg);
	    if (!$validate->check($data)) {
		    //如果验证不通过则错误页面并显示错误信息，3s后跳转指定页面
		    echo '没通过';exit;
	    }else {
		    //通过后则正常进行
		    echo 1;exit;
	    }
    }

    public function test2()
    {
	    $phpWord = \PhpOffice\PhpWord\IOFactory::load('./testword.docx');
	    $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "HTML");
	    $xmlWriter ->save('./ceshi.htm');
    }

    public function sendNotice(){
        //new 类
        $WeChatPush = new WechatMessage('公众号appid', '公众号secret');
        //模板内容(字段对应你申请的模板字段)
        $data       = array(
            'first'    => array('value' => urlencode("您好,您发布的项目"), 'color' => "#743A3A"),
            'keyword1' => array('value' => urlencode("审核通过"), 'color' => '#743A3A'),
            'keyword2' => array('value' => urlencode(date('Y-m-d H:i:s', time())), 'color' => '#743A3A'),
            'remark'   => array('value' => urlencode('请随时关注站内消息！'), 'color' => '#743A3A'),
        );
        //调用发送推送方法
        $result = $WeChatPush->push('用户openid', "模板id", "跳转URL",$data);
    }

}
